import React from 'react';
import styles from './GoodsPagger.css';
import GoodsPaggerItem from './GoodsPaggerItem';
 export const pageSize=2
 function getPaggerDom(totalPage,dispatch,statecurPage) {
  let items=[]
  for (let i=0;i<totalPage;i++){
    items.push(<GoodsPaggerItem curPage={i} key={i}
              dispatch={dispatch} statecurPage={statecurPage}>
      {i+1}
    </GoodsPaggerItem>)
  }
  return items;
}
function GoodsPagger(props) {
  let totalCnt=props.goods.content.length
  let totalPage=Math.ceil(totalCnt/pageSize)
  return (
    <div className={styles.normal}>
      {getPaggerDom(totalPage,props.dispatch,props.goods.curPage)}
    </div>
  );
}

export default GoodsPagger;
